﻿using System;
using AutoPoco.Engine;

namespace AutoPoco.DataSources
{
    public abstract class RandomElementSource<T> : DatasourceBase<T>
    {
        protected Random mRandom = new Random(1337);
        public abstract T[] _elements { get; }

        public override T Next(IGenerationContext context)
        {
            return _elements[mRandom.Next(0, _elements.Length)];
        }
    }

    public class RandomElementSourceImpl<T> : RandomElementSource<T>
    {
        private readonly T[] _enum;

        public RandomElementSourceImpl(params T[] @enum)
        {
            _enum = @enum;
        }

        public override T[] _elements
        {
            get { return _enum; }
        }
    }
}